package com.springframework.boot.common.utils;

import java.util.Random;

public class CommonUtils {

    /**
     * 生成N位的盐
     * @param n
     * @return
     */
    public static String getRandomSalt(int n){
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~！@#￥%……&*（）-=+.".toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char aChar = chars[new Random().nextInt(chars.length)];
            sb.append(aChar);
        }
        return sb.toString();
    }
}
